package com.reason.register.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.reason.register.dao.RegisterMapper;
import com.reason.register.service.RegisterService;
import com.reason.user.pojo.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

/**
 * @author tang wei
 * @version 1.0
 * @date 2020/6/30 15:13
 */
@Service
public class RegisterServiceImpl implements RegisterService {
    @Autowired
    private RegisterMapper registerMapper;
    /**
     * 通过手机号查询用户的信息
     * @param phone
     * @return
     */
    @Override
    public Customer findCustomerByPhone(Long phone) {
        //定义手机号相等进行条件查询
        QueryWrapper<Customer> queryWrapper =new QueryWrapper<>();
        queryWrapper.eq("phone",phone);
        return registerMapper.selectOne(queryWrapper);
    }
    /**
     * 添加客户
     * @param customer
     */
    @Override
    public void addCustomer(Customer customer) {
        registerMapper.insert(customer);
    }
}
